import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class DoubleColorBall {
    public static void main(String[] args) {
        // 红球号码范围：1-33，蓝球号码范围：1-30
        int redBallRange = 33;
        int blueBallRange = 30;

        // 生成2组7+2复式号码
        for (int i = 0; i < 2; i++) {
            ArrayList<Integer> redBalls = new ArrayList<Integer>();
            ArrayList<Integer> blueBalls = new ArrayList<Integer>();

            // 生成7个红球号码
            for (int j = 0; j < 7; j++) {
                int redBall = generateRandomNumber(redBallRange, redBalls);
                redBalls.add(redBall);
            }

            // 生成2个蓝球号码
            for (int j = 0; j < 2; j++) {
                int blueBall = generateRandomNumber(blueBallRange, blueBalls);
                blueBalls.add(blueBall);
            }

            // 排序
            Collections.sort(redBalls);
            Collections.sort(blueBalls);

            // 输出结果
            System.out.print("红球号码：");
            for (int j = 0; j < redBalls.size(); j++) {
                System.out.print(redBalls.get(j) + " ");
            }

            System.out.print("蓝球号码：");
            for (int j = 0; j < blueBalls.size(); j++) {
                System.out.print(blueBalls.get(j) + " ");
            }

            System.out.println();
        }
    }

    // 生成一个随机数，范围为1-range，且不在excludeList中，等待时间为5-17秒
    public static int generateRandomNumber(int range, ArrayList<Integer> excludeList) {
        Random random = new Random();
        int number;
        do {
            number = random.nextInt(range) + 1;
        } while (excludeList.contains(number));
        int waitTime = random.nextInt(13) + 5;
        try {
            Thread.sleep(waitTime * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return number;
    }
}
